package com.tongtailian.www.stir.activity;

import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.tongtailian.www.stir.R;


/**
 * 崩溃弹框
 */
public class CrashDialogActivity extends Activity {

    private TextView dialog_text;

    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_carash_dialog);
        dialog_text = findViewById(R.id.dialog_text);
//        CrashHandler.getInstance().uploadCrashInfo();
        //DialogUtils.showCrashDialog("5 秒后整机重启",this);
        new CountDownTimer(3 * 1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                dialog_text.setText(millisUntilFinished / 1000 + " 秒后程序退出！");
            }

            @Override
            public void onFinish() {
                // 执行重启命令
               /* Intent intent = new Intent(CrashDialogActivity.this, WelcomeActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
                        Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);*/
                exit();
            }
        }.start();
    }


    private void exit() {
        System.exit(0);
        android.os.Process.killProcess(android.os.Process.myPid());
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        exit();
    }


}

